package com.tanjun.data.service;

import com.tanjun.common.enums.queue.DelayQueueTypeEnum;
import com.tanjun.data.components.RedisDelayQueueUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DelayQueueService {
    @Autowired
    private RedisDelayQueueUtil redisDelayQueueUtil;

    /**
     * 向队列中添加消息
     *
     * @param typeEnum
     * @param data
     * @return
     */
    public boolean addDelayQueue(DelayQueueTypeEnum typeEnum, Object data) {
        return redisDelayQueueUtil.addDelayQueue(typeEnum.getQueueName(), typeEnum.getDelayTime(), typeEnum.getTimeUnit(), data);
    }
}
